def consumer():
    r = ''
    print("c1")
    while True:
        #for i in range(10):
        print("c2")
        print(f"r is {r}")
        n = yield r #返回r后就结束了，n为新的调用传递过来的参数，第一次传递过来的None没有用到；到了yield后就返回了当前的值后就停止了，从外部send参数赋值给n启动新一轮计算
        print("c3")
        print(n)
        if not n:
            return
        print('[CONSUMER] Consuming %s...' % n)
        r = '200 OK'

def produce(c):
    print("p1")
    c.send(None)#返回""
    print("p2")
    n = 0
    while n < 5:
        n = n + 1
        print('[PRODUCER] Producing %s...' % n)
        r = c.send(n)
        print('[PRODUCER] Consumer return: %s' % r)
    c.close()

c = consumer()
produce(c)